<?php
//迭代模式（自定义的）
interface Iproject{
    public function getProjectInfo();
}

class Project implements Iproject{
    private $name;
    private $number;
    private $cost;

    public function __construct($name,$number,$cost){
        $this->name=$name;
        $this->number=$number;
        $this->cost=$cost;
    }

    public function getProjectInfo()
    {
       echo "项目名称：".$this->name." 项目人数：".$this->number." 项目费用：".$this->cost;
    }

}

interface PIterator{
    public function hasNext();
    public function next();
    public function remove(Project $project);
    public function add(Project $project);
}

class Projects implements PIterator{
    private $list=array();
    private $next;

    public function __construct(){
        $this->next=-1;
    }

    public function next()
    {
        if($this->hasNext()){
            return $this->list[$this->next];
        }
    }

    public function remove(Project $project)
    {
        if(in_array($this->list,$project)){
            $k=array_search($this->list,$project);
            unset($this->list[$k]);
        }
    }


    public function hasNext(){
        if($this->next>=0&&$this->next<count($this->next)){
            return true;
        }else{
            return false;
        }
    }

    public function add(Project $project){
        return array_push($this->list,$project);
    }

}

$array=array(0,1,2,3,4,5,6,7,8);
unset($array[3]);
print_r($array);
?>